//
//  GestureUIImageView.m
//  UI07_homework
//
//  Created by aaaaaa on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "GestureUIImageView.h"


@implementation GestureUIImageView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addTap];
    }
    return self;
}

- (instancetype)initWithImage:(UIImage *)image{
    self = [super initWithImage:image];
    if (self) {
        self.userInteractionEnabled = YES;
        [self addTap];
        
    }
    return self;
}

//添加点击手势
- (void)addTap{
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self addGestureRecognizer:tap];
    [tap release];
}

//点击的时候调用代理方法
- (void)tapAction:(UIGestureRecognizer *)tap{
    [self.delegate nextViewController:self];
}

@end
